<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单列表</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="../../css/aui.css">
     <link rel="stylesheet" href="../../css/common.css">
         <script type="text/javascript" src="../../script/api.js"></script>
    <script language="JavaScript" src="../../script/vue.js"></script>
     <script language="JavaScript" src="../../script/common.js"></script>
    <link rel="stylesheet" href="../../css/orderitem.css">
    <style>
        .aui-tab-item.aui-active{
            color:#e02e24;
            border-bottom: 2px solid #e02e24;
        }
    </style>
</head>
<body>

<div class="aui-content" id="order-box">

<div class="orderlist aui-margin-b-5">
    <!--orderitem start-->
  <div class="order-item" v-for="item in orders"  @click="godetail(item)">
 <div class="shop-item bg-white">
     <div class="shop-title">
         <img :src="item.shop_logo_url" class="shoplogo">
         <span>{{item.shop_title}}</span>
     </div>
     <div class="orderstatus">{{item.tiptxt}}</div>
 </div>
     <div class="product">
         <div class="product-logo-title">
             <img :src="item.product_tumbpic_url" class="product-logo">
             <div class="product-title">
             <div class="product-titled">{{item.product_title}}</div>
             <p>{{item.product_sku}}</p>
         </div>
          </div>

         <div class="price-and-num">
             <div class="product-price">￥{{item.product_price/100}}</div>
             <div class="product-num">x{{item.product_num}}</div>
         </div>
     </div>
      <div class="pay-info bg-white">
        实付: ￥{{item.pay_amount/100}}
       </div>
        <div class="productbtn bg-white">
            <div v-if="item.pay_status>0">
             <span v-if="item.status==1 && item.wuliu_status==1" @click="checksign(item)">等待签收</span>
            <span class="orderbtn">订单详情</span>
             <span v-if="item.status==1" @click="gocomment(item)">{{commentmap[item.comment_status]}}</span>

            </div>
            <!-- <div v-else><span class="paybtn">立即支付</span></div> -->
        </div>
      </div>
    <!--orderitem  end-->


  </div>
</div>
</div>

<script>
    var vm = new Vue({
        el:"#order-box",
        data:{
          token:'',
           page:1,
           totalpage:1,
           retback:true,
           orders:[],
           status:'',
            commentmap:{
              0:'未评论',
              1:'已评论',
           }
        },
        methods:{
            checksign:function (item) {
                console.log(item);
                //签收货物
                if(item.wuliu_status<2){
                     $page.get_data('/api/order/checksign','post', {orderid:item.id,token:this.token},function (ret) {
                         for (var i in vm.orders) {
                             vm.orders[i].wuliu_status =2;
                         }
                    });
                }
            },
            gocomment:function (item) {
                if(!item.comment_status){
                  $page.openwin('product_addcomment','../product/addcomment.html',{orderid:item.id,product_id:item.product_id});

                }

            },
            godetail:function (item) {
              $page.openwin('home_orderdetail','./orderdetail.html',{id:item.id});
             },

             godeail:function (item) {
              $page.openwin('home_orderdetail','./orderdetail.html',{id:item.id});
             },
            goluck:function (item) {
               $page.openwin('product_luckuser','../product/luckuser.html',{id:item.id});
             },
            getorderlist:function () {
                if(vm.page>vm.totalpage || !vm.retback){
                    return;
                }
                vm.retback =false;
                var param={  'token':this.token};
                if(this.status=='wait_pay'){
                    param={
                        'pay_status':0,
                          'token':this.token
                    };
                }else if(this.status=='wait_pin'){
                    param={
                        'pay_status':1,
                        'status':0,
                          'token':this.token
                    };
                }else if(this.status=='wait_send'){
                    param={
                        'pay_status':1,
                        'status':1,
                        'wuliu_status':0,
                          'token':this.token
                    };
                }else if(this.status=='wait_recv'){
                    param={
                        'pay_status':1,
                        'status':1,
                        'wuliu_status':1,
                        'token':this.token,
                    };
                }
                $page.get_data('/api/order/getList','post',param,function (ret) {
                    vm.totalpage = ret.data.totalpage;
                    vm.page = vm.page+1;
                    vm.retback = true;
                    if(ret.errno==1000){
                        ret.data.list.forEach(function(el){
                            vm.orders.push(el);
                        });
                    }else{
                        $page.toast(ret.errmsg);
                    }
                });
            }
        }
    });
    apiready=function(){
      vm.token = $api.getStorage('token');
      $page.init();
      var pageParam = api.pageParam;
      vm.status = pageParam.status;
  vm.getorderlist();
      $page.pullreload(function(){

      });

            $page.pullup(function (ret) {
              vm.getorderlist();
            });
    }


</script>
</body>
</html>
